home *** CD-ROM | disk | FTP | other *** search
-
- ' TSR (Memory Resident) Phone or Fax Dialer, 1200 Baud
- ' by Kauko J. Laurinolli 404-981-9550
- ' Feb. 15, 1987
-
- ' Be my quest, use, modify, improve and mutilate this Freebie code the way you wish
- ' No Guarantee of any kind provided
-
- ' STAYRES and MACH2 Copyrighted by Micro-Help
-
- ' Sample Compiled with Qbasic V2.01, works also with V1.01 or V2.00
- ' Linked with MS-Link V3.06
-
- ' qb dial.asc/o;
- ' link stayres+dial/e+gwcom,,nul,bcom20+mhlib
-
- ' Program uses EMS memory if available
- ' Activate with Alt X
-
- ' This program uses couple of great programmers utilities:
- '╔═════════════════════════════════════════════════════════════════════╗
- '║ Stay-Res Program Package to Make Basic Program Resident and ║
- '║ Mach 2 Program Package to Speed-Up Basic ║
- '║ Both programs are available from Micro-Help, Inc ║
- '║ Phone No: 404-973-9272 or 1-800-922-3383 ║
- '╚═════════════════════════════════════════════════════════════════════╝
-
- rem $linesize: 132
- rem $pagesize: 55
- rem $title: 'Phone or Telefax Dialer with Stayres'
-
- defint a-z
-
- dim shared nam$(500)
-
- common shared new.time$,filename$,stack$
- common shared dtaseg,nor,hi,rev,pages,page
- common shared start.line,end.line,last.cursor.line,last.rec
-
- '--------------------------- CALLS ------------------------------------
- 'call mhwind(stack$,nor,dtaseg,oper,page,top.row,left.col,bot.row,right.col,buf.no,box,ecode)
- 'call mhscr(page,lin$,row,col,colr)
- 'call hotkey(oper,kscan,kshift,ecode)
- '----------------------------------------------------------------------
- scr.buffer$ = space$(4050) 'reserve memory
- kshift = varptr(scr.buffer$) 'get segment address
-
- stack$="": page= 0
-
- '--- get monitor type
- call get.monitor (last.monitor,nor,hi,rev,curs.normal,curs.insert,start.line,end.line)
-
- filename$="TELEFAX.NUM"
-
-
- '-------------------------- PRINT MESSAGE -----------------------------
-
- cls
- call mhscr(page,"╔══════════════════════╗", 1, 1, 7)
- call mhscr(page,"║ Resident FAX or ║", 2, 1, 7)
- call mhscr(page,"║ Phone Dialer ║", 3, 1, 7)
- call mhscr(page,"║ by Micro-Help ║", 4, 1, 7)
- call mhscr(page,"║ and KJL ║", 5, 1, 7)
- call mhscr(page,"║ Version 1.11 ║", 6, 1, 7)
- call mhscr(page,"║ Activate with Alt X ║", 7, 1, 7)
- call mhscr(page,"╚══════════════════════╝", 8, 1, 7)
-
- call GET.NAMES(NAM$(),1) 'get names, first time
-
- call GET.DATA.TIME(CODE,NEW.TIME$) 'get name-file time, first time
-
- old.time$=new.time$
-
- '----------------------------- INITIALIZE -----------------------------
-
- call mhmt16(dtaseg,box) 'call for space
- call mhwind(stack$, 0,dtaseg, 0, 0, 0, 0, 0, 0, 2,box*16,ecode)
-
- if ecode <> 0 then call mach2.error("MHWIND",ecode)
-
- '----------------- ALLOCATE STRING SPACE FOR SCREEN STORAGE -----------
-
- hot.oper= 3
- call hotkey(hot.oper,kscan,kshift,h.ecode)
-
- if h.ecode <> 0 then call hotkey.error(hot.oper,ecode)
-
- '-------------------- WHERE TO STORE SCREEN IMAGE ---------------------
-
- kscan = 4000 'bytes to save text only
- call hotkey( 4,kscan,kshift,h.ecode) 'set storage segment and number of bytes
- if h.ecode <> 0 then call hotkey.error(hot.oper,ecode)
-
- '----------------------- SWAP TO RAM DISK -----------------------------
-
- goto NO.SWAP 'rem this line to use swap to disk
-
- dir$ = "f:\" 'RAM Disk to swap
- kshift = varptr(dir$) 'get segment address
- kscan = 0
- hot.oper = 7
-
- call hotkey(hot.oper,kscan,kshift,h.ecode) 'set storage segment and number of bytes
- if h.ecode <> 0 then call hotkey.error(hot.oper,ecode)
-
- NO.SWAP:
-
- '----------------------- TERMINATE AND STAY RESIDENT ------------------
-
- hot.oper= 0
- locate last.cursor.line+1,1,1,start.line,end.line 'cursor location
-
- HOT.KEY:
-
- kscan=&h2D: kshift=8: h.ecode= 0
- call hotkey(hot.oper,kscan,kshift,h.ecode) 'Terminate and Stay Res. HOT-KEY = Alt X
-
- '--- get monitor type
- call get.monitor (monitor,nor,hi,rev,curs.normal,curs.insert,start.line,end.line)
-
- if last.monitor <> monitor then _
- call mhvideo(monitor): last.monitor=monitor ' change monitor
-
- if (kscan=2 and monitor=&hB800) or _
- (kscan=3 and monitor=&hB800) or _
- (kscan=7 and monitor=&hB000) then goto NO.CHANGE
-
- hot.oper= 2
- call hotkey(hot.oper, 3,kshift,h.ecode) 'change video mode
-
- if h.ecode <> 0 then call hotkey.error(hot.oper,ecode)
-
- NO.CHANGE:
-
- if h.ecode < 0 or h.ecode > 1 then call hotkey.error(hot.oper,ecode)
-
-
- '------------- CHECK IF DATA-FILE HAS BEEN UPDATE AND RE-READ ---------
-
- if h.ecode = 1 then goto DRAW.BOX
-
- call GET.DATA.TIME(CODE,NEW.TIME$) 'get datafiles date
- if code=258 then goto HOT.KEY 'data file missing
-
- call GET.HR.MIN.SEC(OLD.TIME$,NEW.TIME$,OLD.SECONDS#,NEW.SECONDS#) 'split time
-
- if old.seconds# <> new.seconds# then call GET.NAMES(NAM$(),2): _
- old.time$ = new.time$
-
-
- '---------------------------- DRAW BOX --------------------------------
-
- DRAW.BOX:
-
- call mhwind(stack$,hi,dtaseg, 4, 0, 2, 1,23,80, 0, 2,ecode)
-
- if ecode <> 0 then call mach2.error("MHWIND",ecode)
-
- '---------------------------- PRINT TEXT ------------------------------
-
- first.record = 1
- rec.per.page =20
- current.page = 1
- cursor.line = 3
- old.cur.line = 3
-
- PRINT.TEXT:
-
- '------------------------------ HEADING -------------------------------
-
- ''FAX DIALER: Page 00 of 99 PgDn Select ──┘ Dial <Esc> Quit ▓
- ''FAX DIALER: Page 00 of 99 PgUp Select ──┘ Dial <Esc> Quit ▓
- ''FAX DIALER: Page 00 of 99 PgDn PgUp Select ──┘ Dial <Esc> Quit ▓
-
- current.page$=mid$(str$(current.page),2,len(str$(current.page))-1)
- last.page$ =mid$(str$(pages), 2,len(str$(pages)) -1)
-
- if len(current.page$) < 2 then current.page$ = " "+current.page$
- if len(last.page$) < 2 then last.page$ = " "+last.page$
-
- if current.page = 1 then _
- call mhscr(page," FAX DIALER: Page "+current.page$+" of "+last.page$+" PgDn Select ──┘ Dial <Esc> Quit ", 1, 1,rev)
-
- if current.page = pages then _
- call mhscr(page," FAX DIALER: Page "+current.page$+" of "+last.page$+" PgUp Select ──┘ Dial <Esc> Quit ", 1, 1,rev)
-
- if current.page > 1 and current.page < pages then _
- call mhscr(page," FAX DIALER: Page "+current.page$+" of "+last.page$+" PgDn PgUp Select ──┘ Dial <Esc> Quit ", 1, 1,rev)
-
-
- '----------------------------- PRINT NAMES ----------------------------
-
- row= 2
-
- for x=first.record to first.record+19
- row=row+1: call mhscr(page,nam$(x),row, 2,nor)
- next
-
- '--- PRINT REVERSE bar
-
- PRINT.LINE:
-
- call mhscatt(page,old.cur.line, 2,nor,78)
- call mhscatt(page, cursor.line, 2,rev,78)
-
-
- '------------------------------ GET KEY -------------------------------
-
- GET.KEY:
-
- kscan=0
- call mhkclr(stack$,curs.normal,lin,col,page,kshift,kscan,kascii)
-
- if kscan=&h1c then call DIAL(CURSOR.LINE): kscan=0: goto get.key 'dial w/ <cr>
-
- '--- Cursor Dn
-
- if kscan=&h50 then _
- if cursor.line <22 then _
- old.cur.line=cursor.line: cursor.line=cursor.line+1: goto PRINT.LINE _
- else _
- if cursor.line =22 then _
- old.cur.line=cursor.line: cursor.line= 3: goto PRINT.LINE
-
- '--- Cursor Up
-
- if kscan=&h48 then _
- if cursor.line > 3 then _
- old.cur.line=cursor.line: cursor.line=cursor.line-1: goto PRINT.LINE _
- else _
- if cursor.line = 3 then _
- old.cur.line=cursor.line: cursor.line=22: goto PRINT.LINE
-
- '--- PgDn
-
- if kscan=&h51 then _
- if rec.per.page < last.rec then _
- first.record=first.record+20: _
- rec.per.page=rec.per.page+20: _
- current.page=current.page+1: _
- for x=3 to 22: call mhscr(page,space$(78),x, 2,nor): next: _
- cursor.line= 3: old.cur.line= 3: goto PRINT.TEXT _
- else goto GET.KEY
-
- '--- PgUp
-
- if kscan=&h49 then _
- if first.record > 1 then _
- first.record=first.record-20: _
- rec.per.page=rec.per.page-20: _
- current.page=current.page-1: _
- for x=3 to 22: call mhscr(page,space$(78),x, 2,nor): next: _
- cursor.line= 3: old.cur.line= 3: goto PRINT.TEXT _
- else goto GET.KEY
-
-
- if kscan=&h01 then goto HOT.KEY 'if Esc then hide again
-
- ' Take REM out of the next line to create key 1 which releases memory Stayres is using
-
- '''' if kscan=&h02 then hot.oper= 9: goto hot.key 'if number 1 entered then end
-
- goto GET.KEY
-
-
- '**********************************************************************
- ' END
- '**********************************************************************
-
- '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- '>>>>>>>>>>>>>>>>>>>>>>>>>>>>> SUBROUTINES <<<<<<<<<<<<<<<<<<<<<<<<<<<<
- '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- SUB DIAL(CURSOR.LINE) STATIC
-
- page=0: num$=space$(22)+chr$(0)
- call mhrscr(page,num$,cursor.line,57,23) 'read number
-
- ln.num=len(num$)
-
- '--- strip trailing spaces from string
-
- LOOP1: if ln.num > 0 then _
- if mid$(num$,ln.num,1)=" " then _
- ln.num=ln.num-1: goto LOOP1
-
- num$ = left$(num$,ln.num): ln.num=1
-
- '--- strip leading spaces from string
-
- LOOP2: if ln.num < len(num$) then _
- if mid$(num$,ln.num,1)=" " then _
- ln.num=ln.num+1: goto LOOP2
-
- num$ = mid$(num$,ln.num)
-
- '--- Open COM 1 Port
-
- OPEN "COM1:1200,E,7,1,CS,DS,CD" AS #1
-
- call OPEN.WINDOW 'open small window
-
- '--- Dial
-
- print #1, "ATM1 S11=40DT"+num$
-
- '--- Print number on screen
-
- col=int((80-len(num$))/2) 'print middle of screen
- call mhscr(page,num$,11,col,hi) 'print number at screen center
-
- ''' 10 ╔═══════════════════════════════════════╗
- ''' 11 ║ 12345678901234567890123 ║
- ''' 12 ║ After Dial Tone ║
- ''' 13 ║ Press Fax Machines Start Button ║
- ''' 14 ║ and Press any key on keybord to SEND ║
- ''' 15 ╚═══════════════════════════════════════╝
-
- call mhscr(page,"After Dial Tone",12,33,hi)
- call mhscr(page,"Press Fax Machines Start Button",13,26,hi)
- call mhscr(page,"and Press any key on keybord to SEND",14,22,hi)
-
- call mhkclr(stack$,curs.normal,lin,col,page,kshift,kscan,kascii)
-
- call CLOSE.WINDOW 'close small window
-
- print #1, "ATM1 H0 Z" 'hang up
- close
-
- end sub 'end sub dial
-
-
- '************************ GET MONITOR TYPE ****************************
-
- SUB GET.MONITOR(MONITOR,NOR,HI,REV,CURS.NORMAL,CURS.INSERT,START.LINE,END.LINE) STATIC
-
- def seg=0
-
- if (peek(&h410) and &h30)=&h30 then _
- nor= 7: hi=15: rev=112: curs.normal=3085: curs.insert=1293: _
- start.line=12: end.line=13: _
- monitor=&hB000: _
- color 7,0,0 _
- else _
- nor=30: hi=31: rev= 79: curs.normal=1543: curs.insert=1031: _
- start.line= 6: end.line= 7: _
- monitor=&hFFFF: _ '&hB800 for color, &hFFFF for no snow-check
- color 7,0,0
-
- def seg
-
- call mhvideo(monitor)
-
- end sub 'get.monitor mono / color
-
-
- '************************** GET NAMES *********************************
-
- 'Name etc -------------------------------------------x 12345678901234567890123 ║
-
- SUB GET.NAMES(NAM$(1),SEQ) STATIC
-
- open filename$ for input as #1
-
- line input #1, nam$(0) 'skip 2 top lines
- line input #1, nam$(0)
-
- if seq=2 then call OPEN.WINDOW: _
- call mhscr(page,"Data Changed, Reloading",11,22,hi) else _
- call mhscr(page,"Loading Data from File", 9, 1, 7): locate 9,24
-
- rec.count=0: row=11: col=45
-
- while not eof(1)
- rec.count=rec.count+1: line input #1, nam$(rec.count)
- if len(nam$(rec.count)) < 78 then nam$(rec.count)=nam$(rec.count)+space$(78-len(nam$(rec.count)))
- if seq=1 then _ '1 st read
- if (rec.count/20)-int(rec.count/20) = 0 then print "*"; 'print on every 20 th record
- if seq=2 then _ '2 nd read
- if (rec.count/20)-int(rec.count/20) = 0 then col=col+1: _
- locate row,col: print "*"; 'print on every 20 th record
- if col=58 then col=21: row=row+1
- wend
-
- last.cursor.line=csrlin: close
- last.rec=rec.count: pages=int(rec.count/20)+1
-
- if seq=2 then call CLOSE.WINDOW
-
- end sub 'get.names
-
-
- '*********************** GET DATA FILE TIME ***************************
-
- SUB GET.DATA.TIME(ECODE,NEW.TIME$) STATIC
-
- new.time$=space$(8): dat$=space$(8)
-
- '-- open file
- file.name$=filename$+chr$(0)
- oper = 0
- call mhfile(stack$,oper,file.name$,mode,attr,handle,ecode)
- if ecode <> 0 then call mach2.error("OPEN FILE",ecode)
-
- '-- get file time
- oper = 1
- call mhfdate(stack$,handle,oper,new.time$,dat$,ecode)
- if ecode <> 0 then call mach2.error("FDATE ERROR",ecode)
-
- '-- close file
- oper = 0
- file.name$=""
- call mhfile(stack$,oper,file.name$,mode,attr,handle,ecode)
- if ecode <> 0 then call mach2.error("CLOSE FILE",ecode)
-
- end sub 'get.data.time
-
-
- '************************ SPLIT TIME **********************************
-
- SUB GET.HR.MIN.SEC(OLD.TIME$,NEW.TIME$,OLD.SECONDS#,NEW.SECONDS#) STATIC
-
- '--- set a number corresponding to old file time
-
- old.seconds# = val(mid$(old.time$,7,2))
- old.seconds# = old.seconds# + val(mid$(old.time$,4,2))*60
- old.seconds# = old.seconds# + val(mid$(old.time$,1,2))*1.11
-
- '--- set a number corresponding to new file time
-
- new.seconds# = val(mid$(new.time$,7,2))
- new.seconds# = new.seconds# + val(mid$(new.time$,4,2))*60
- new.seconds# = new.seconds# + val(mid$(new.time$,1,2))*1.11
-
- end sub 'get.hr.min.sec
-
- '************************ OPEN SMALL BOX ******************************
-
- SUB OPEN.WINDOW STATIC
-
- '--- Save text under small window
-
- call mhwind(stack$, 0,dtaseg, 1,page,10,20,15,60, 1, 0,ecode)
- if ecode <> 0 then call mach2.error("MHWIND",ecode)
-
- '--- clear small window
-
- for row=10 to 15
- call mhscr(page,space$(40), row,20,nor)
- next
-
- '--- draw small box
-
- call mhwind(stack$,hi,dtaseg, 4,page,10,20,15,60, 1, 1,ecode)
- if ecode <> 0 then call mach2.error("MHWIND",ecode)
-
- ''' 10 ╔═══════════════════════════════════════╗
- ''' 11 ║ ║
- ''' 12 ║ ║
- ''' 13 ║ ║
- ''' 14 ║ ║
- ''' 15 ╚═══════════════════════════════════════╝
-
- end sub 'open.window
-
- '************************* CLOSE SMALL BOX ****************************
-
- SUB CLOSE.WINDOW STATIC
-
- kscan=0
- call mhwind(stack$, 0,dtaseg, 2,page,10,20,15,60, 1, 0,ecode) 'Restore small window
- if ecode <> 0 then call mach2.error("MHWIND",ecode)
-
- end sub 'close.window
-
- '************************ MACH2 ERROR DISPLAY *************************
-
- defint a-z
-
- SUB MACH2.ERROR(OPERATION$,ECODE) STATIC
-
- call mhscr( 0,operation$+", Mach2 Error ="+str$(ecode), 1, 1,15)
-
- kscan=0
- call mhkclr(stack$,curs.normal,lin,col,page,kshift,kscan,kascii)
-
- end sub 'mach2.error
-
-
- '************************ HOTKEY ERROR DISPLAY ************************
-
- defint a-z
-
- SUB HOTKEY.ERROR(OPERATION,ECODE) STATIC
-
- if ecode=-1 then error$="Don't invoke Operation or 7 after TSR"
- if ecode= 1 then error$="DOS functions not available"
- if ecode= 2 then error$="Not enough memory for TSR"
- if ecode= 3 then error$="TSR was unsuccesfull, terminate"
- if ecode= 4 then error$="Use DOS 3.0 or later"
- if ecode= 5 then error$="You have to Link STAYRES.OBJ before Your code"
- if ecode= 6 then error$="DOS busy,unsuccesfull attempt to release memory"
- if ecode= 7 then error$="Unsuccesfull attempt to un-install program"
- if ecode= 8 then error$="Hotkey needs to know where to store the screen image"
-
- if ecode=10 then error$="Files SR00 - SR99 Used already"
-
- '------------------------ show error ----------------------------------
-
- call mhscr( 0,"Operation = "+str$(operation)+" Hotkey Error ="+str$(ecode)+" , "+error$, 1, 1,15)
-
- kscan=0
- call mhkclr(stack$,curs.normal,lin,col,page,kshift,kscan,kascii)
-
- end sub 'hotkey.error
-
-
- '************************ SYSTEM ERROR DISPLAY ************************
-
- defint a-z
-
- SUB MHDOS2.ERROR(OPERATION$,ECODE) STATIC
-
- retcd=ecode
-
- if retcd=255 then goto NO.ERRORS
- if retcd>256 then goto HI.CODE
-
- if retcd=0 then error$="Attempt to write on write-protected diskette"
- if retcd=1 then error$="Unknown unit"
- if retcd=2 then error$="Drive not ready"
- if retcd=3 then error$="Unknown command"
- if retcd=4 then error$="Data error (CRC)"
- if retcd=5 then error$="Bad request structure length"
- if retcd=6 then error$="Seek error"
- if retcd=7 then error$="Unknown media type"
- if retcd=8 then error$="Sector not found"
- if retcd=9 then error$="Printer out of paper"
- if retcd=10 then error$="Write fault"
- if retcd=11 then error$="Read fault"
- if retcd=12 then error$="General failure"
-
- goto SHOW.ERR
-
- HI.CODE:
- retcd=retcd-256
- if retcd=1 then error$="Invalid function number"
- if retcd=2 then error$="File not found"
- if retcd=3 then error$="Path not found"
- if retcd=4 then error$="Too many open files"
- if retcd=5 then error$="Access denied"
- if retcd=6 then error$="Invalid handle"
- if retcd=7 then error$="Memory control blocks destroyed"
- if retcd=8 then error$="Insufficient memory"
- if retcd=9 then error$="Invalid memory block address"
- if retcd=10 then error$="Invalid environment"
- if retcd=11 then error$="Invalid format"
- if retcd=12 then error$="Invalid access code"
- if retcd=13 then error$="Invalid data"
- if retcd=15 then error$="Invalid drive was specified"
- if retcd=16 then error$="Attempted to remove the current directory"
- if retcd=17 then error$="Not same device"
- if retcd=18 then error$="No more files"
- if retcd=19 then error$="Disk write protected"
- if retcd=20 then error$="Unknown unit"
- if retcd=21 then error$="Drive not ready"
- if retcd=22 then error$="Unknown command"
- if retcd=23 then error$="Data Error (CRC)"
- if retcd=24 then error$="Bad request structure lenght"
- if retcd=25 then error$="Seek error"
- if retcd=26 then error$="Unknown media type"
- if retcd=27 then error$="Sector not found"
- if retcd=28 then error$="Printer out of paper"
- if retcd=29 then error$="Write fault"
- if retcd=30 then error$="Read fault"
- if retcd=31 then error$="General failure"
- if retcd=32 then error$="Sharing violation"
- if retcd=33 then error$="Lock violation"
- if retcd=34 then error$="Invalid disk change"
- if retcd=35 then error$="FCB unavaialable"
- if retcd=36 then error$="Sharing buffer overflow"
- if retcd=50 then error$="Network request not supported"
- if retcd=51 then error$="Remote computer not listening"
- if retcd=52 then error$="Duplicate name on network"
- if retcd=53 then error$="Network name not found"
- if retcd=54 then error$="Network busy"
- if retcd=55 then error$="Network device no longer exist"
- if retcd=56 then error$="Net BIOS command limit exeeded"
- if retcd=57 then error$="Network adapter hardware error"
- if retcd=58 then error$="Incorrect response from network"
- if retcd=59 then error$="Unexpected network error"
- if retcd=60 then error$="Uncompatible remote adapter"
- if retcd=61 then error$="Print Queue full"
- if retcd=62 then error$="Not enough space for print file"
- if retcd=63 then error$="Print file deleted"
- if retcd=64 then error$="Network name deleted"
- if retcd=65 then error$="Access denied"
- if retcd=66 then error$="Network device type incorrrect"
- if retcd=67 then error$="Network name not found"
- if retcd=68 then error$="Network name limit exeeded"
- if retcd=69 then error$="Net BIOS session limit exeeded"
- if retcd=70 then error$="Temporarily paused"
- if retcd=71 then error$="Network request not accepted"
- if retcd=72 then error$="Print/disk redirection paused"
- if retcd=80 then error$="File alredy exist"
- if retcd=82 then error$="Cannot make directory entry"
- if retcd=83 then error$="Interupt 24H failure"
- if retcd=84 then error$="Too many redirections"
- if retcd=85 then error$="Duplicate redirection"
- if retcd=86 then error$="Invalid Password"
- if retcd=87 then error$="Invalid parameter"
- if retcd=88 then error$="Network device fault"
-
- SHOW.ERR:
- if retcd <> 255 then cls: _
- call mhscr( 0,operation$+", Error ="+str$(retcd)+", "+error$, 1, 1,15): _
- else goto NO.ERRORS
-
- kscan=0
- call mhkclr(stack$,curs.normal,lin,col,page,kshift,kscan,kascii)
-
- NO.ERRORS:
- end sub 'error display
-
-